	<?php $this->load->view('common/head')?>
	
	<!-- Begin of Sidebar -->
	<?php $this->load->view('common/sidebar')?>
	
	<?php /*********************************/ ?>
	
	
	<style>
		th {background:#284860;color:#fff}
		
		td.middle {vertical-align:middle;text-align:center}
	</style>
	
	<div id="dialog-confirm" title="Delete?" style="display: none;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This Company will be permanently deleted and cannot be recovered. Are you sure?</p>
	</div>
	
	    <!-- Begin of #main -->
    <div id="main" role="main">
    	
    	<!-- Begin of titlebar/breadcrumbs -->
		<div id="title-bar">
			<ul id="breadcrumbs">
				<li><a href="dashboard.html" title="Home"><span id="bc-home"></span></a></li>
				<li><a href="<?php echo site_url('/admin/admin/')?>" title="Admin Spot">Admin Spot</a></li>
				<li><a href="<?php echo site_url('/admin/permission/')?>" title="Roles">Permissions</a></li>
				<li class="no-hover">Main</li>
			</ul>
		</div> <!--! end of #title-bar -->
		
		<div class="shadow-bottom shadow-titlebar"></div>
		
		<!-- Begin of #main-content -->
		<div id="main-content">
			<div class="container_12">
			
			
			<div class="grid_12">
				<div class="block-border">
				<div class="block-header"><h1>Permissions</h1></div>
				<div class="block-content">
						<div class="block-actions">
							<ul class="actions-right">
								<li><button class="submit" onClick="load_form()">Add New Permission</button></li>
							</ul>
						</div>
					</div>
					</div>
			</div>
			
			<!--  -->

			
			<!-- Example Block with Border -->
			<div class="grid_7">
				<div class="block-border">
					<div class="block-header">
						<h1>Permissions List</h1><span></span>
					</div>
					<div class="block-content">
						<p>
							<table width=100% border=1 cellpadding=3 cellspacing=3>
							<tr>
								<th> Module </td>
								<th> Action </td>
								<th> Description </th>
								<th> Status </th>
								<th> Edit </th>
								<th> Delete </th>
							</tr>
							<?php foreach($list as $permission):?>
							<tr id="tr_<?php echo $permission->id?>">
								<td class="middle"><a href="javascript:;" onClick="load_info(<?php echo $permission->id?>)"><?php echo $permission->controller?></a></td>
								<td class="middle"><a href="javascript:;"><?php echo $permission->alias_name?></a></td>
								<td><?php echo $permission->description?></td>
								<td><img src="<?php echo $this->config->item('images')?>/icons/packs/fugue/16x16/acorn.png" alt="<?php echo $permission->status?>" title="<?php echo $permission->status?>" /></td>
	
								<td class="middle"><a href="javascript:;" onClick="load_form(<?php echo $permission->id?>)"><img src="<?php echo $this->config->item('images')?>/icons/packs/fugue/16x16/pencil.png" alt="Edit <?php echo $permission->description?>" title="Edit <?php echo $permission->description?>" /></a></td>
								<td class="middle"><a href="javascript:;" onClick="del(<?php echo $permission->id?>)"><img src="<?php echo $this->config->item('images')?>/icons/packs/fugue/16x16/slash.png" alt="Delete <?php echo $permission->description?>" title="Delete <?php echo $permission->description?>" /></a></td>
							</tr>
							<?php endforeach?>
							</table>
						</p>
					</div>
				</div>
			</div>
			
			<!--  -->
			<div class="grid_5">
				<div class="block-border">
					<div class="block-header">
						<h1 id="for_title">Options & Settings for (permissions)</h1><span></span>
					</div>
					<div class="block-content ">
						<div class="load_option"></div>
					</div>

				</div>
			</div>
		
		
			<div class="clear height-fix"></div>

		</div></div> <!--! end of #main-content -->
  </div> <!--! end of #main -->

	
	<script type="text/javascript">
	
	
	$().ready(function(){
		
	});
	
	</script>
	
	<?php /****************************/ ?>
	<script type="text/javascript">

		/** load_form **/
		function load_form(id)
		{
			$('.load_option').slideUp('slow');
			$('#for_title').html('<center><img src="<?php echo $this->config->item('images')?>/loading2.gif" alt="Loading..." title="Loading..." /> Loading... </center>');
			if(id==null)
			{
				//load empty form
				$('.load_option').load('permission/form', function() {
				  $('#for_title').html('Add New Permission');
				  $('.load_option').slideDown('slow');
				});
			}
			else{
				//load form
				$('.load_option').load('permission/form/'+id, function() {
				  $('#for_title').html('Edit Permission');
				  $('.load_option').slideDown('slow');
				});
			}
		}
		/** END load_form **/
		
		/** function Delete **/
		function del(com)
		{
			$( "#dialog-confirm" ).dialog({
				resizable: false,
				height:150,
				modal: true,
				buttons: {
					"Are You Sure ? (Yes Delete!)": function() {
							temp_title = $('#for_title').html();
							//$('#for_title').html('<center><img src="<?php echo $this->config->item('images')?>/loading2.gif" alt="Loading..." title="Loading..." /> Loading... </center>');
							$.post("<?php echo site_url('admin/permission/delete/')?>/"+com,
								function(data){
									//alert(data)
									if(!data.error){
										$('#tr_'+com).effect("highlight", {color: 'red'}, 1500).fadeOut(1500);
										$.jGrowl( data.msg, { theme: 'saved',position:'center'  });
									}
									else{
										$.jGrowl('Error: '+data.msg, { theme: 'error',position:'center'  });
										//$('#for_title').html(temp_title);
									}
							},'json');
							$( this ).dialog( "close" );
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				}
			});
			
			
		}
		/** End function Delete **/
	</script>
	
	
	<?php /*********************************/ ?>
	<!-- Begin of footer -->
	<?php $this->load->view('common/footer')?>
